package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.Task;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TaskDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "任务名称")
    private String taskName;

    @ApiModelProperty(value = "任务内容")
    private String content;

    @ApiModelProperty(value = "优先级：1低2中3高")
    private Integer priority;

    @ApiModelProperty(value = "创建人id")
    private Integer createAdminId;

    @ApiModelProperty(value = "负责人id")
    private Integer chargeAdminId;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date stopTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "是否删除 0否 1是")
    private Integer isDelete;


    public TaskDTO() {}

    public TaskDTO(Task entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static TaskDTO convert(Task entity) {
        return new TaskDTO(entity);
    }

    public static List<TaskDTO> convertList(List<Task> list) {
        List<TaskDTO> resultList = new ArrayList<>();
        for (Task entity : list) {
            resultList.add(new TaskDTO(entity));
        }
        return resultList;
    }}
